From 608c1e40eb776f57c58350cbe55f239599391006 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sun, 20 Feb 2011 17:03:45 -0500 Subject: [PATCH] Remove no-longer existing API from the migration guide Some parts of the migration guide were written before the demise of pixmaps, and still referred to pixmap API in their replacements. --- docs/reference/gtk/migrating-2to3.xml | 28 ++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/docs/reference/gtk/migrating-2to3.xml b/docs/reference/gtk/migrating-2to3.xml index d68fe30432..7bb3619105 100644 --- a/docs/reference/gtk/migrating-2to3.xml +++ b/docs/reference/gtk/migrating-2to3.xml @@ -217,9 +217,6 @@ gdk_cairo_set_source_pixbuf (cr, pixbuf, x, y); cairo_paint (cr); cairo_destroy (cr); - Note that very similar code can be used for drawing pixmaps - by using gdk_cairo_set_source_pixmap() instead of - gdk_cairo_set_source_pixbuf(). @@ -246,17 +243,20 @@ gdk_gc_set_ts_origin (gc, 0, 0); The equivalent cairo code looks like this: cairo_t *cr; +cairo_surface_t *surface; -cr = gdk_cairo_create (drawable); -gdk_cairo_set_source_pixmap (cr, pixmap, x_origin, y_origin); +surface = ... +cr = gdk_cairo_create (window); +gdk_cairo_set_source_surface (cr, surface, x_origin, y_origin); cairo_pattern_set_extend (cairo_get_source (cr), CAIRO_EXTEND_REPEAT); cairo_rectangle (cr, 0, 0, width, height); cairo_fill (cr); cairo_destroy (cr); - Again, you can exchange pixbufs and pixmaps by using - gdk_cairo_set_source_pixbuf() instead of - gdk_cairo_set_source_pixmap(). +The surface here can be either an image surface or a X surface, +and can either be created on the spot or kept around for caching purposes. +Another alternative is to use pixbufs instead of surfaces with +gdk_cairo_set_source_pixbuf() instead of cairo_set_source_surface(). @@ -339,7 +339,7 @@ gtk_color_button_get_checkered (void) stippling is absent from text rendering, in particular #GtkTextTag. - Using the the target drawable also as source or mask + Using the target also as source or mask The gdk_draw_drawable() function allowed using the same drawable as source and target. This was often used to achieve a scrolling @@ -356,20 +356,26 @@ gdk_draw_drawable (pixmap, By using this code: -cairo_t *cr = gdk_cairo_create (pixmap); +cairo_t *cr = gdk_cairo_create (window); /* clipping restricts the intermediate surface's size, so it's a good idea * to use it. */ gdk_cairo_rectangle (cr, &area); cairo_clip (cr); /* Now push a group to change the target */ cairo_push_group (cr); -gdk_cairo_set_source_pixmap (cr, pixmap, dx, dy); +gdk_cairo_set_source_surface (cr, surface, dx, dy); cairo_paint (cr); /* Now copy the intermediate target back */ cairo_pop_group_to_source (cr); cairo_paint (cr); cairo_destroy (cr); +The surface here can be either an image surface or a X surface, +and can either be created on the spot or kept around for caching purposes. +Another alternative is to use pixbufs instead of surfaces with +gdk_cairo_set_source_pixbuf() instead of cairo_set_source_surface(). + + The cairo developers plan to add self-copies in the future to allow exactly this effect, so you might want to keep up on cairo development to be able to change your code. -- 2.30.2